package com.yn.bsc.web.api;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import com.github.pagehelper.PageInfo;
import com.yn.bsc.core.Result;
import com.yn.bsc.core.ResultGenerator;
import com.yn.bsc.model.Menu;
import com.yn.bsc.model.UserInfo;
import com.yn.bsc.service.MenuService;
import com.yn.bsc.vo.MenuBean;

/**
 * 用户菜单 Created by ZuoLG on 2017/09/18.
 */
@RestController
@RequestMapping("/api/menu")
public class MenuController extends BaseController<MenuService, Menu> {
	@Resource
	private MenuService menuService;

	/**
	 * 获取指定用户的菜单 @return Result @throws
	 */
	@SuppressWarnings("rawtypes")
	@RequestMapping("/listUserAllMenu")
	public Result listUserAllMenu(@RequestParam Integer id) {
		if (id == null || id == 0) {
			return ResultGenerator.genFailResult("用户登录对象不能为空！");
		}

		UserInfo user = new UserInfo();
		user.setId(id);
		List<MenuBean> list = menuService.selectUserMenuAll(user);
		@SuppressWarnings("unchecked")
		PageInfo pageInfo = new PageInfo(list);
		return ResultGenerator.genSuccessResult(pageInfo);
	}
}
